module.exports = class extends think.Model {

	getMyDeviceList(patientId){
		return this.where({patient_id:patientId}).select();
	}



	getDeviceList(){
		return this.select();
	}

	async getDeviceTypeId(deviceId){
		let deviceType = await this.where({id:deviceId}).find();
        return deviceType.type_id.toString();
    }

	getHistoryList(deviceTypeId,deviceId,current,pageSize){
		let model = {};
		switch (deviceTypeId){
			case '1':
				model = this.model('dvt_report');
				break;

			default:
				break;
		}
		return model.where({'device_id':deviceId}).page(current,pageSize).select();
	}

	async getReportDetail(deviceTypeId,reportId){
		let model = {};
		switch (deviceTypeId){
			case '1':
				model = this.model('dvt_report');
				break;

			default:
				break;
		}
		let result = await model.where({'id':reportId}).find(),
			content = result.content;
		return JSON.parse(content);
	}
};
